package com.security.frame.core.authentication;

import com.security.frame.core.common.CommonConstants;
import com.security.frame.core.properties.SecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

/**
 * todo
 *
 * @author wangjie
 * @version V1.0
 * @date 2019/12/11
 */
@Component
@Order(Integer.MIN_VALUE)
public class FrameAuthorizeConfigProvider implements AuthorizeConfigProvider {

    @Autowired
    private SecurityProperties securityProperties;

    @Override
    public void config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {

        registry.antMatchers(CommonConstants.DEFAULT_UNAUTHENTICATION_URL,
                CommonConstants.DEFAULT_LOGIN_PROCESSING_URL_MOBILE,
                CommonConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX+"/*",
                securityProperties.getCommon().getSignUpUrl(),
                CommonConstants.DEFAULT_SESSION_REGIST_URL,
                securityProperties.getSession().getSessionInvalidUrl(),
                securityProperties.getCommon() .getLoginPage()).permitAll();
    }
}
